package leecode

func guessNumber(n int, target int) int {
	left := 1
	right := n
	for left <= right {
		mid := (left + right) >> 1
		if mid < target {
			left = mid + 1
		} else if mid > target {
			right = mid - 1
		} else {
			left = mid
			goto End
		}
	}
End:
	return left
}
